package com.wysql.iostream;

import java.io.*;
import java.util.Arrays;

public class CharStream {
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new FileReader("IOstream/src/filebook/b.txt"));
        String s = br.readLine();
        System.err.println(s);
        br.close();

        String[] s1 = s.split(" ");
        //3.把字符串类型的数组变成int类型
        int [] arr = new int[s1.length];
        //遍历split数组，可以进行类型转换。
        for (int i = 0; i < s1.length; i++) {
            String smallStr = s1[i];
            //类型转换
            int number = Integer.parseInt(smallStr);
            //把转换后的结果存入到arr中
            arr[i] = number;
        }
        //4.排序
        Arrays.sort(arr);
        System.out.println(Arrays.toString(arr));

        BufferedWriter bw = new BufferedWriter(new FileWriter("IOstream/src/filebook/c.txt"));
        for (int i = 0; i < s1.length; i++) {
            bw.write(arr[i]+"");
            bw.newLine();
            bw.flush();
        }
        bw.close();
    }
}
